|
|
Okay, Phil posted a reply since I started messing with this, but here
goes anyway....
I've typically added text to simple shapes a different way - I make a
union of the base object and an intersection of the "text" with a
similar shape that is very slightly larger. That way the text is above
the sphere/cylinder, but imperceptibly so. Sort of what would happen if
the text was a layer of paint on the object surface.
In your case, the face color can be applied the same way, too. I
modified your macro, adding a "text" texture at the end (and the scaling
and translation is unnecessarily different, since I was tweaking it to
see what you were doing). In any event, here's an example of what I mean:
-------- SNIP --------
#macro MakeTextBall(Text, SpotSize, SpotClearance, SphereTex, FaceTex,
TextPig)
#local TextObj = text {ttf "crystal.ttf", Text, 1, 0 };
#local Mn = min_extent(TextObj);
#local Mx = max_extent(TextObj);
union {
// First, the sphere:
sphere {< 0, 0, 0>, 1 texture {SphereTex}}
// Next, the color behind the text:
intersection {
cylinder {-z*2, z*2, SpotSize/2}
sphere { <0,0,0>, 1.0001 }
texture{FaceTex}
}
// Last, the text:
intersection {
union {
#local ii=0; #while (ii<2)
object {TextObj
translate -Mn - 0.5*(Mx-Mn)
scale
<-1,1,0>*(SpotSize-SpotClearance)/vlength(<Mx.x,Mx.y,0>-<Mn.x,Mn.y,0>)+z/(Mx.z-Mn.z)
translate -z*1
#if (ii) rotate 180*x #end
}
#local ii=ii+1; #end
}
sphere { <0,0,0>, 1.0002 }
texture{TextPig}
}
}
#end
-------- SNIP --------
In this case the sphere is 1.0000 in radius, the "face" color is 1.0001
and the text is 1.0002 -- giving the layered effect I was trying to
describe.
Note that this method doesn't "wrap" the text, so if the text covers
much of an arc on the object, it may be distorted too much.
Ralf wrote:
> Hello Everybody!
>
> I trying to arrange labelled balls on a grid (see subsequent code). The
> problem is that the balls look like pool balls. To become more reliable I
> would like use uni-colored balls labelled with black text.
>
> error.
>
Post a reply to this message
|
|